Bring over embeddings support from the PHP AI Client - #892
Conversation
…r custom Vendor directory
…om us instead of Core if needed
…and to also generate embeddings
…. May remove before merging the PR
…Client things in the future we want to load, those can all be handled independently of one another
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #892 +/- ##
=============================================
- Coverage 80.31% 75.46% -4.85%
- Complexity 2591 2924 +333
=============================================
Files 111 121 +10
Lines 10536 11597 +1061
=============================================
+ Hits 8462 8752 +290
- Misses 2074 2845 +771
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ode. Modify it a bit to have detection be lazy, meaning it only detects support when needed instead of all the time
What?
Brings the embedding related changes over from the PHP AI Client and loads those conditionally when needed, allowing us to start supporting that work.
Why?
Embedding supported was added to v1.4.0 of the PHP AI Client. We were hoping to get this in to WordPress 7.1 but that has been pushed now to 7.2. Instead of having to wait until WordPress 7.2 is released to take advantage of this new functionality, this PR pulls that code into the AI plugin, behind a conditional gate, so we can start taking advantage of that earlier.
How?
includes/Vendor/AiClientdirectorySDK_Overlayclass that loads this code, if needed, on top of the code WordPress itself loads. This allows us to continue to use the PHP AI Client that ships with WordPress while also loading in this new embedding code. This approach can be used in the future for any other PHP AI Client changes we want to start using soonerUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Brainstorming and planning the initial approach and then executing on that approach. Final review and testing by me
Testing Instructions
Easiest way to test is via the custom WP-CLI command this PR has. Note you'll also need to install an AI Provider plugin that supports embeddings.
wp ai embeddings generate 'This is some text'Dry run: would have generated embeddings for text: This is some textwp ai embeddings generate 'This is some text' --dry-run=falsewp ai embeddings generate --post-id=42 --dry-run=falsewp ai embeddings generate --post-id=42 --chunk --dry-run=falsewp ai embeddings generate 'This is some text' --provider=ollama --dry-run=falseChangelog Entry